From c154195fa161575363280aac9e928b7225f0de9e Mon Sep 17 00:00:00 2001
From: "Yann E. MORIN" <yann.morin.1998@free.fr>
Date: Sun, 29 Dec 2019 17:42:13 +0100
Subject: [PATCH] configure: fix detection of fltk libs

Chaining calls to AC_CHECK_LIB one in the other, breaks the configure
script, because some internal functions (e.g. ac_fn_c_try_link) would
not be defined before they are needed, leading the build to fail as
thus:

    checking for snd_tplg_new in -latopology... ./configure: line 4630:
    ac_fn_c_try_link: command not found
    no
    configure: error: No linkable libatopology was found.

Using AC_CHECK_LIB() in sequence (i.e. one after the other) and
memorising the result is not trivial: AC_CHECK_LIB() implements a
ddefault action-if-found that append to LIBS, but not if the user
ptrovides their own action-if-found.

Instead, AC_SEARH_LIBS() always append to LIBS, *and* run the
user-provided action.

So, we switch to AC_SEARCH_LIBS() and memorise the result for each
test, to eventually test if ether worked.

Signed-off-by: Yann E. MORIN <yann.morin.1998@free.fr>
---
 configure.in | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/configure.in b/configure.in
index 9307cc2..55f6864 100644
--- a/configure.in
+++ b/configure.in
@@ -11,10 +11,10 @@ AC_PROG_INSTALL
 AC_PROG_LN_S
 
 dnl Checks for libraries.
-AC_CHECK_LIB(fltk,numericsort,,
-AC_CHECK_LIB(fltk,fl_numericsort,,
-AC_MSG_ERROR("missing fltk"))
-)
+has_fltk=false
+AC_SEARCH_LIBS(numericsort,fltk,has_fltk=true)
+AC_SEARCH_LIBS(fl_numericsort,fltk,has_fltk=true)
+AS_IF(test "${has_fltk}" = "false", AC_MSG_ERROR("missing fltk"))
 AM_PATH_ALSA(0.9.0)
 
 dnl Checks for header files.
-- 
2.20.1

